package PUSHReciveParser;

public class DeliveryInd {
	private String deliveryIndMessage;
	
	public static final String MMS_MESSAGE_TYPE = "X-Mms-Message-Type: ";
	public static final String MMS_VERSION = "X-Mms-Message-Version: ";
	public static final String MMS_MESSAGE_ID = "Message-ID: ";
	public static final String MMS_TO = "To"; 
	public static final String MMS_FROM = "From";
	public static final String MMS_STATUS = "X-Mms-Status"; 
	
	private String mmsMessageType;
	private String mmsVersion;
	private String mmsMessageId;
	private String mmsTo;
	private String mmsFrom;
	private String mmsStatus;
	
	public String getMessageType(){
		return mmsMessageType;
	}
	
	public String getVersion(){
		return mmsVersion;
	}
	
	public String getMessageId(){
		return mmsMessageId;
	}
	
	public String getTo(){
		return mmsTo;
	}
	
	public String getFrom(){
		return mmsFrom;
	}
	
	public String getStatus(){
		return mmsStatus;
	}
	
	public DeliveryInd(String deliveryIndMessage) {
		this.deliveryIndMessage = deliveryIndMessage;
	}
	
	public void parseMessage(){
		
		try{
			String[] result = deliveryIndMessage.split("\n");
			
			int i=0;			
			for(i=0 ; i<result.length ; i++);
			{
				if(result[i].startsWith(MMS_MESSAGE_TYPE))
					mmsMessageType=(result[i].substring((result[i].indexOf(':'))+1));
				
				else if(result[i].startsWith(MMS_VERSION))
					mmsVersion=result[i].substring((result[i].indexOf(':'))+1); 
				
				else if(result[i].startsWith(MMS_MESSAGE_ID))
					mmsMessageId=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_TO))
					mmsTo=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_FROM))
					mmsFrom=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_STATUS))
					mmsStatus=result[i].substring((result[i].indexOf(':'))+1);
			}
			
		}catch (ArrayIndexOutOfBoundsException e){
			System.out.println("Malformed response message");
		}
	}
}